<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="number" name="number" id="number">
    <input type="number" name="result" id="result">
    <button id="calc">计算阶乘</button>
</body>
<script>
    const worker = new Worker('work.js')
    document.getElementById('calc').addEventListener('click',()=>{
        const value = document.getElementById('number').value
        worker.postMessage({
            value: value
        })
    })
    worker.addEventListener('message',({data:{res}})=>{
        const resdom = document.getElementById('result')
        resdom.value = res
        // worker.terminate()
    })
</script>
</html>